//
//  CustomAlertViewController.m
//  ModelFromJson
//
//  Created by 王冠晓(总行零售网络金融) on 2018/12/11.
//  Copyright © 2018 w. All rights reserved.
//

#import "CustomAlertViewController.h"

@interface CustomAlertViewController ()

@property (nonatomic, weak) IBOutlet UIButton *imgButton;
@property (nonatomic, weak) IBOutlet UILabel *titLab;
@property (nonatomic, weak) IBOutlet UILabel *descLab;
@property (nonatomic, weak) IBOutlet UIButton *backButton;
@property (nonatomic, weak) IBOutlet UIButton *exchangeButton;

@property (nonatomic, copy) NSString *titleStr;
@property (nonatomic, copy) NSString *descStr;
@property (nonatomic, assign) CustomAlertStyle style;
@property (nonatomic, copy) CustomAlertViewControllerBlock block;
@end

@implementation CustomAlertViewController


- (IBAction)dismiss
{
    [self dismissViewControllerAnimated:YES completion:NULL];
}

+ (instancetype)instanceWithType:(CustomAlertStyle)style title:(NSString *)title desc:(NSString *)desc Complete:(CustomAlertViewControllerBlock)block;
{
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"CustomAlert" bundle:[NSBundle mainBundle]];
    CustomAlertViewController *vc = [storyboard instantiateInitialViewController];
    vc.titleStr = title;
    vc.descStr = desc;
    vc.style = style;
    vc.block = block;
    return vc;
}

- (void)viewDidLoad {
    [super viewDidLoad];

    self.titLab.text = self.titleStr;
    self.descLab.text = self.descStr;
    
    
    self.imgButton.frame = CGRectMake(0, 0, self.imgButton.frame.size.width, 2000);
    [self.imgButton updateConstraints];
    
    switch (self.style) {
        case CustomAlertStyleSuccess:// 成功
            [self.imgButton setImage:@"" forState:UIControlStateNormal];
            break;
        case CustomAlertStyleFail:// 失败
            [self.imgButton setImage:@"" forState:UIControlStateNormal];
            break;
        case CustomAlertStyleAuthen:// 去认证
            [self.imgButton setBackgroundImage:[UIImage imageNamed:@"bg_popup"] forState:UIControlStateNormal];
            break;
        case CustomAlertStyleCerting:// 审核中
            [self.backButton setTitle:@"返回" forState:UIControlStateNormal];
            [self.imgButton setImage:[UIImage imageNamed:@"aut_bg_examine"] forState:UIControlStateNormal];

            break;
        default:
            break;
    }
    
}

- (IBAction)nextAction:(id)sender
{
    if (self.block) {
        self.block(YES, NO);
    }
    [self dismissViewControllerAnimated:YES completion:^{
        
    }];
}

// 切换账号
- (IBAction)exchangeUser:(id)sender
{
    self.block(NO, YES);
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
